<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js" type="text/javascript"></script>
</head>
<body>
    <div id="app">
        <cpn1></cpn1>
        <cpn1></cpn1>
        <cpn2></cpn2>
    </div>
    <!-- 创建组件模板 -->
    <script type="text/x-template" id="cpn">
        <div>
            <h2>标题1</h2>
            <p>段落1</p>
        </div>
    </script>
    <!--  -->
    <script>
        // 注册组件语法糖
        Vue.component("cpn1", {
            template: '#cpn'
        });
        // 注册局部组件的语法糖
        var app = new Vue({
            el: "#app",
            data: {
                message: "hello"
            },
            components: {
                cpn2: {
                    template: `
                    <div>
                        <h2>局部标题1</h2>
                        <p>局部段落1</p>
                    </div>
                    `
                }
            }
        });
    </script>
</body>
</html>